package com.example.interview.no0104.solution;

import com.example.interview.no0104.Solution;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description 解答-回文排列
 * @ClassName ArraySolution
 * @Author Administrator
 * @Date 2020/7/7 19:36
 * @Version 1.0.0
 */
public class MapSolution implements Solution {
    @Override
    public boolean canPermutePalindrome(String s) {
        Map<Character, Integer> map = new HashMap<>();
        int length = s.length()%2;
        for (char c: s.toCharArray()) {
            if(map.containsKey(c)){
                map.remove(c);
            } else {
                map.put(c, 1);
            }
        }
        return length == map.size();
    }
}
